using System;
using System.Reflection;
using SeguradoraIA.Framework.Configuration;

namespace SeguradoraIA.Framework.Data
{
    public static class DAOFactory
    {
        public static T CreateDAO<T>()
        {
            try
            {
                string[] part = Configurator.GetInstance().GetDaoFactoryConfiguration(typeof(T).FullName).Split('|');
                return (T)Assembly.Load(part[0]).CreateInstance(part[1]);
            }
            catch (Exception ex)
            {
                throw new Exception("DaoFactory - Nao foi possivel obter instancia para " + typeof(T).FullName, ex);
            }
        }
    }
}